Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #2700

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

solution #2700

wants to merge 3 commits into from

Conversation

mykyta01
Copy link

@mykyta01 mykyta01 commented Aug 7, 2023

No description provided.

Copy link

@lerastarynets lerastarynets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start! Let's fix and improve your work a little bit)

break;

case 'removeProperties':
if (keysToRemove) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary condition. If 'keysToRemove' is not provided, the for...of loop will simply not run. Therefore, the if (keysToRemove) condition is redundant and can be removed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

case 'removeProperties':
if (keysToRemove) {
for (const key of keysToRemove) {
if (state.hasOwnProperty(key)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hasOwnProperty check is not necessary when deleting a property. JavaScript will not throw an error if you try to delete a property that does not exist. Thus, this line can be safely removed.

@@ -6,6 +6,36 @@
*/
function transformState(state, actions) {
// write code here
for (const action of actions) {
const { type, extraData, keysToRemove } = action;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent destructuring of 'action'. The task description mentions that the second property of the action object can vary depending on the type, but here you're destructuring 'extraData' and 'keysToRemove' regardless of the type. You should move the destructuring inside the corresponding case blocks.

break;

case 'removeProperties':
if (keysToRemove) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

@mykyta01 mykyta01 requested a review from xiimiik August 7, 2023 15:28
Copy link

@Esceype Esceype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants